package com.example.demo.service.Impl;

import com.example.demo.domain.Picture;
import com.example.demo.repository.PictureMapper;
import com.example.demo.service.PictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PictureServiceImpl implements PictureService {

    @Autowired
    private PictureMapper pictureMapper;


    @Override
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public Picture getPictureById(Integer id) {
        return pictureMapper.getPictureById(id);
    }

    @Override
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public List<Picture> getPictureListByGid(Integer gid) {
        return pictureMapper.getPictureListByGid(gid);
    }


    @Override
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public void addPicture(Picture picture) {
        pictureMapper.addPicture(picture);
    }

    @Override
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public void delPictureById(Integer id) {
        pictureMapper.delPictureById(id);
    }

    @Override
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public void savePicture(Picture picture) {
        pictureMapper.savePicture(picture);
    }
}
